package com.easyj.admin.sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import com.easyj.base.cache.SysCacheUtil;
import com.easyj.base.common.ajax.Result;
import com.easyj.base.controller.BaseController;
import com.easyj.base.enums.ImpEnum;
import com.easyj.base.common.page.Page;
import com.easyj.admin.db.model.ImpResult;
import com.easyj.admin.db.model.ImpResultQO;
import com.easyj.admin.sys.service.ImpResultService;
	/**
	* 数据导入结果
	*
	 */
	@RestController
	@RequestMapping(value = "/sys/impresult")
	public class ImpResultController extends BaseController{

		@Autowired
		private  ImpResultService impResultService;

		/**
		 * get
		 * @param id
		 * @return
		 */
	    @GetMapping("/{id}")
	    public Result get(@PathVariable("id") Long id) {
	        ImpResult entity = impResultService.findById(id);
	        return Result.Success(entity);
	    }
		
				

		/**
		* 分页查询
		* @param filter
		* @return
		 */
	    @PreAuthorize("hasPermission('impResult','impResult:all')")
		@PostMapping(value = "findPage")
		public Result findPage(@RequestBody  ImpResultQO filter) {
		    if(filter.getPage().getLimit()>MaxLimit) {
				return Result.Error(10009,"超出一次读取最大行数"); 
			}
			Page<ImpResult>  page =impResultService.findPage(filter);
			if(page!=null && page.getRows()!=null ){
				for(ImpResult r:page.getRows()){
					r.setOperatorName(SysCacheUtil.getOperatorName(r.getOperatorId()));
					r.setStatusName(ImpEnum.getText(r.getStatus()));
				}
			}
			return Result.Success(page);
			
		}
		
        

}

